package com.ctp.thread.factory;

import javax.swing.table.DefaultTableModel;

import com.ctp.thread.active.AccountUpdateThread;
import com.ctp.thread.active.MarketUpdateThread;
import com.ctp.thread.daemon.ProfitUpdateThread;
import com.ctp.thread.passive.ITraderProcessor;
import com.ctp.thread.passive.TraderListenThread;
import com.jbooktrader.platform.trader.Trader;
import com.manualtrader.thread.ManualTradeThread;

public class ThreadFactory {

	private static MarketUpdateThread marketThread = new MarketUpdateThread();

	private static AccountUpdateThread accountThread = new AccountUpdateThread();

	private static TraderListenThread traderThread = new TraderListenThread();

	private static ProfitUpdateThread profitThread = new ProfitUpdateThread();

	private static ManualTradeThread manualTradeThread = new ManualTradeThread();
	

	public static void strartManualTradeThread(DefaultTableModel tModel,Trader trader){
		manualTradeThread.setTableModel(tModel, trader);
		manualTradeThread.start();
	}
	
	public static void startMarketThread(DefaultTableModel tModel) {
		marketThread.setTableModel(tModel);
		marketThread.start();
	}

	public static void startAccountThread(DefaultTableModel tModel) {
		accountThread.setTableModel(tModel);
		accountThread.start();
	}

	public static void startTraderThread(DefaultTableModel formModel) {
		traderThread.setFormTableModel(formModel);
		traderThread.start();
	}

	public static void startProfitThread(DefaultTableModel singleModel,Trader trader) {
		profitThread.setSingleTableModel(singleModel,trader);
		profitThread.start();
	}

	public static void setSingleTableForTrade(DefaultTableModel singleModel) {
		traderThread.setSingleTableModel(singleModel);
	}

	public static ITraderProcessor getTraderProcessor() {
		return traderThread;
	}

}
